#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMessageBox>

#include <QVBoxLayout>

#include <QProgressBar>

#include <QList>

#include <QTime>
#include <QTimer>
#include <QElapsedTimer>

#include <QFile>
#include <QDir>
#include <QIODevice>

#include "games/startgame.h"
#include "games/checkgame.h"
#include "games/buttongame.h"
#include "games/hovergame.h"
#include "games/endgame.h"
#include "games/slidergame.h"
#include "games/waitgame.h"
#include "games/memorygame.h"
#include "games/randomgame.h"
#include "games/colorgame.h"
#include "games/lineeditgame.h"
#include "games/progressgame.h"
#include "games/blackjackgame.h"
#include "games/mazegame.h"

#include "tools.h"
#include "halloffamedisplay.h"

namespace Ui {
class MainWindow;
}

// MainWindows subclasses QMainWindow handling everithing
class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    void setupStatusBar();

    void newGame(int index);
    void setWidget(int index);

    void saveToHallOfFame(QString name, int points, int time);
    void displayHallOfFame();

public slots:
    void onResetButtonClicked();
    void onHintButtonClicked();
    void onCheckButtonClicked();
    void onNextButtonClicked();
    void onSkipButtonClicked();
    void onPointsModification(int diff);

    void setDiffLevel(int diff_lvl);
    void onLowerDiffLvlButtonClicked();
    void onRaiseDiffLvlButtonClicked();

    // Updates
    void updateGameInfo();
    void updatePoints();
    void updateTime();
    
private:
    Ui::MainWindow *ui;
    QVBoxLayout * lay;

    BaseGame * current_widget;
    int current_index;

    int completed_games;
    int skipped_games;
    int hinted_games;
    int total_games() { return TOTAL_GAMES; }
    int total_skip() { return SKIPPABLE_GAMES; }
    int total_hints() {return HINTABLE_GAMES; }

    int difficulty_level;

    int temp_game_points;
    int game_points;
    int completed_points;
    int time_points;
    int skipped_points;
    int hint_points;
    int total_points() { return game_points + completed_points + time_points + skipped_points + hint_points; }

    QString hall_of_fame_dir;

    QTimer * clock;
    QElapsedTimer * global_elapsed;
    QElapsedTimer * local_elapsed;
    int last_completed;

    QLabel * points_status;
    QLabel * progress_status;
    QProgressBar * progressbar_status;
};

#endif // MAINWINDOW_H
